def display(triangle):
    print ('\n'.join(" ".join(str(num)for num in row).center(len(triangle) * 2)for row in triangle))
def generate(n):
    triangle = []
    for i in range(n):
        row = [1] * (i+1)
        triangle.append(row)
        for j in range(1,i):
            row[j]=triangle[i-1][j-1]+triangle[i-1][j]
    return  triangle
display(generate(5))
